﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.SilverlightMediaFramework.Player;

namespace SMF.HowTo.Sample
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            this.player.MarkerData = new MarkerData();
            LoadMarkers();
        }

        private void LoadMarkers()
        {
            this.player.MarkerData.Markers.Clear();

            CustomMarker marker;
            marker = new CustomMarker
            {
                Time = TimeSpan.Parse("00:00:30"),
                Description = "Marker 1"
            };
            marker.Selected += new Action<Marker>(marker_Selected);
            this.player.MarkerData.Markers.Add(marker);

            marker = new CustomMarker
            {
                Time = TimeSpan.Parse("00:01:30"),
                Description = "Marker 2"
            };
            marker.Selected += new Action<Marker>(marker_Selected);
            this.player.MarkerData.Markers.Add(marker);
        }

        void marker_Selected(Marker marker)
        {
            this.player.MediaElement.Position = marker.Time;
        }
    }
}
